#include <errno.h>
#include <signal.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <libusb.h>


struct libusb_device_handle *devh = NULL;

static int find_dpfp_device(void)
{
	devh = libusb_open_device_with_vid_pid(NULL, 1118, 688);
	return devh ? 0 : -EIO;
}

int main(void){
	struct sigaction sigact;
	int r = 1;
	
	printf("Step 0\n");	
	r = libusb_init(NULL);
	if (r < 0) {
		fprintf(stderr, "failed to initialise libusb\n");
		exit(1);
	}
	
	printf("Step 1\n");
	r = find_dpfp_device();
	if (r < 0) {
		fprintf(stderr, "Could not find/open device\n");
		exit(1);
	}
		
	printf("Step 2\n");
	r = libusb_claim_interface(devh ,0);
	if( r < 0){
	fprintf(stderr, "usb_claim_interface error %d\n", r);
		printf("Step 2 exit");
		exit(0);
	}

	char buffer[4];	
	printf("Loop Step\n");	
	int i;
	for( i=0 ; i < 255 ; i++ ){	
	int k;	

	k = libusb_control_transfer(devh, 0xC0 , i, 0, 0, buffer, 1, 0);
	if(k == 1){
		printf("bRequest %d\n", i);
		printf("%d\n", k);
	}

	}
	exit(1);
}
